#include "memory_app.h"
#include "memory_board.h"
#include "device_parameter.h"
// extern void Flash_Test(void);
/**
 * @brief 更新设备参数回调
 *
 */
static void UpdateDeviceParameterCallback(void);

static void UpdateDeviceParameterCallback(void)
{
  uint8_t mac[8];
  bool UpdateResult = WriteDeviceParametersToMemory();
  PRINT("[system]: update decice parametes result: %d.\r\n", UpdateResult);
  // GetLockMac(mac);
  // Flash_Test_Fast();
  // Flash_Test();
}

void MemoryUpdateDeviceParameters(void)
{
  MemoryDelayedStartUpdateParameterTask(DELAY_IN_UPDATE_DEVICE_PARAMETERS);
}

void MemoryUpdateDeviceParametersNoWait(void)
{
  MemoryStartUpdateParameterTaskNoWait();
}

void MemoryLoadDeviceParametersFromMemory(void)
{
  LoadDeviceParameterFromMemory();
}

void MemoryInitialisingdeviceparameters(void)
{
  LoadDeviceParameterFromMemory();
  PRINT("[system]: load user configuration data.\r\n");

  uint8_t DeviceStatus = GetDeviceInitStatus();
  InitialisingDeviceParameters();
  PRINT("[info]: DeviceStatus = %d\r\n", DeviceStatus);
  PRINT("[system]: compare firmware version numbers.\r\n");
  char FirmwareVersionNumber[NUMBER_OF_FIRMWARE_VERSION] = {0};

  GetDeviceFirmwareVersion(FirmwareVersionNumber);
  PRINT("[system]: firmware version : %s.\r\n", FirmwareVersionNumber);
  

}

void MemoryConfiguartion(void)
{
  MemoryExternalInterfaces_t ExternalInterfaces = {0};

  ExternalInterfaces.UpdateDeviceParmaeterTask = UpdateDeviceParameterCallback;
  MemoryBoardInitialisation(&ExternalInterfaces);
}
